package com.code.constant;

import java.util.Arrays;
import java.util.Optional;

public enum DataTypeEnum {

    BIGINT("bigint", "number"),
    INT("int", "number"),
    VARCHAR("varchar", "varchar2"),
    DECIMAL("decimal", "number"),
    CHAR("char", "char"),
    BLOB("blob", "blob"),
    TEXT("text", "clob"),
    MEDIUMTEXT("mediumtext","clob"),
    TINYINT("tinyint", "number"),
    DOUBLE("double", "float"),
    DATE("date", "date"),
    DATETIME("datetime", "date"),
    TIMESTAMP("timestamp", "date");

    private String mysqlType;
    private String oracleType;

    DataTypeEnum(String mysqlType, String oracleType) {
        this.mysqlType = mysqlType;
        this.oracleType = oracleType;
    }

    public static Optional<DataTypeEnum> getOracleTypeByMysqlType(String mysqlType) {
        return Arrays.stream(values()).filter(
            dataTypeEnum -> dataTypeEnum.getMysqlType().equals(mysqlType.trim().toLowerCase())
        ).findFirst();
    }

    public String getMysqlType() {
        return mysqlType;
    }

    public String getOracleType() {
        return oracleType;
    }

}
